package com.app.couponsharelife.ui.viewfactory
import android.util.SparseArray
import com.app.couponsharelife.base.LazyFragment
import com.app.couponsharelife.data.bean.HomeClassBean
import com.app.couponsharelife.ui.main.shop.pddfragment.PDDGoodsListFrag

/**
 *Created by xct on 2019/1/16
 *Description:
 */
class PddFragmentFactory {
    private val mFragments = SparseArray<LazyFragment>()
    fun createFragment(position: Int,homeClassBean: HomeClassBean): LazyFragment {
        var fragment: LazyFragment? = mFragments.get(position)
        if (fragment == null) {
            when (position) {
                0 -> fragment = PDDGoodsListFrag.newInstance(homeClassBean) //精选
                1 -> fragment = PDDGoodsListFrag.newInstance(homeClassBean) //热销
                2 -> fragment = PDDGoodsListFrag.newInstance(homeClassBean)
                3 -> fragment = PDDGoodsListFrag.newInstance(homeClassBean)
                4 -> fragment = PDDGoodsListFrag.newInstance(homeClassBean)
                5 -> fragment = PDDGoodsListFrag.newInstance(homeClassBean)
                6 -> fragment = PDDGoodsListFrag.newInstance(homeClassBean)
                7 -> fragment = PDDGoodsListFrag.newInstance(homeClassBean)
                8 -> fragment = PDDGoodsListFrag.newInstance(homeClassBean)
                9 -> fragment = PDDGoodsListFrag.newInstance(homeClassBean)
                10 -> fragment = PDDGoodsListFrag.newInstance(homeClassBean)
                11 -> fragment = PDDGoodsListFrag.newInstance(homeClassBean)
                12 -> fragment = PDDGoodsListFrag.newInstance(homeClassBean)
                13 -> fragment = PDDGoodsListFrag.newInstance(homeClassBean)
                14 -> fragment = PDDGoodsListFrag.newInstance(homeClassBean)
                15 -> fragment = PDDGoodsListFrag.newInstance(homeClassBean)
                16 -> fragment = PDDGoodsListFrag.newInstance(homeClassBean)
            }
            if (fragment != null) {
                mFragments.put(position, fragment)
            }
        }
        return fragment!!
    }
}